package com.reuters.rfa.example.omm.gui.viewer;


import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author nitin.parmar
 */
public class TraceOptions extends javax.swing.JDialog {

    /**
     * Creates new form TraceOptions
     */
    public TraceOptions(UserOptions userOps, java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        parentFrame = parent;
        userOptions = userOps;
        setLocationRelativeTo( parentFrame );
        initComponents();
        setDefaultActions();
    }

    private void setDefaultActions() {
        this.getRootPane().setDefaultButton(okButton);
        JRootPane rootPane = this.getRootPane();
        InputMap iMap = rootPane.getInputMap( JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape");
        ActionMap aMap = rootPane.getActionMap();
        aMap.put(
                "escape", new
                AbstractAction()
                    {
                        public void actionPerformed(ActionEvent e)
                        {
                            cancelDomainActionPerformed(null);
                        }
                    }
                );
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        inputTracing = new javax.swing.JCheckBox();
        outputTracing = new javax.swing.JCheckBox();
        genericDataTracing = new javax.swing.JCheckBox();
        hexDataTracing = new javax.swing.JCheckBox();
        xmlDataTracing = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        normalDomains = new javax.swing.JCheckBox();
        directoryDomain = new javax.swing.JCheckBox();
        dictionaryDomain = new javax.swing.JCheckBox();
        marketByPriceDomain = new javax.swing.JCheckBox();
        marketMakerDomain = new javax.swing.JCheckBox();
        rankedSymbolListDomain = new javax.swing.JCheckBox();
        historyDomain = new javax.swing.JCheckBox();
        newsHeadlineDomain = new javax.swing.JCheckBox();
        newsStoryDomain = new javax.swing.JCheckBox();
        newsHeadlineReplayDomain = new javax.swing.JCheckBox();
        newsStoryReplayDomain = new javax.swing.JCheckBox();
        transactionDomain = new javax.swing.JCheckBox();
        marketPriceDomain = new javax.swing.JCheckBox();
        symbolListDomain = new javax.swing.JCheckBox();
        yieldCurveDomain = new javax.swing.JCheckBox();
        loginDomain = new javax.swing.JCheckBox();
        marketByOrderDomain = new javax.swing.JCheckBox();
        okButton = new javax.swing.JButton();
        cancelDomain = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        mountTrace = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("RFA Trace Options");
        setAlwaysOnTop(true);
        setModal(true);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("ipcTraceFlags");

        inputTracing.setText("Input Tracing");
        inputTracing.setToolTipText("Set 0x01 in ipcTraceFlags (enables input tracing)");

        outputTracing.setText("Output Tracing");
        outputTracing.setToolTipText("Set 0x02 in ipcTraceFlags (enables output tracing)");

        genericDataTracing.setText("Generic Data Tracing");
        genericDataTracing.setToolTipText("Set 0x04 in ipcTraceFlags (enables generic data tracing)");

        hexDataTracing.setText("HEX Data Tracing");
        hexDataTracing.setToolTipText("Set 0x08 in ipcTraceFlags (enables hex data tracing)");

        xmlDataTracing.setText("XML Data Tracing");
        xmlDataTracing.setToolTipText("Set 0x10 in ipcTraceFlags (enables xml data tracing)");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(xmlDataTracing)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(genericDataTracing)
                            .addComponent(inputTracing))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(outputTracing)
                            .addComponent(hexDataTracing))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(inputTracing)
                    .addComponent(outputTracing))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(genericDataTracing)
                    .addComponent(hexDataTracing))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(xmlDataTracing)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("traceMsgDomains");

        normalDomains.setText("Normal (all domains except Dictionary)");
        normalDomains.setToolTipText("Set traceMsgDomains to include all domains except DICTIONARY");
        normalDomains.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                normalDomainsItemStateChanged(evt);
            }
        });

        directoryDomain.setText("Directory");
        directoryDomain.setToolTipText("Set traceMsgDomains to include DIRECTORY");

        dictionaryDomain.setText("Dictionary");
        dictionaryDomain.setToolTipText("Set traceMsgDomains to include DICTIONARY");

        marketByPriceDomain.setText("Market By Price");
        marketByPriceDomain.setToolTipText("Set traceMsgDomains to include MARKET_BY_PRICE");

        marketMakerDomain.setText("Market Maker");
        marketMakerDomain.setToolTipText("Set traceMsgDomains to include MARKET_MAKER");

        rankedSymbolListDomain.setText("Ranked Symbol List");
        rankedSymbolListDomain.setToolTipText("Set traceMsgDomains to include RANKED_SYMBOL_LIST");

        historyDomain.setText("History");
        historyDomain.setToolTipText("Set traceMsgDomains to include HISTORY");

        newsHeadlineDomain.setText("News Headline");
        newsHeadlineDomain.setToolTipText("Set traceMsgDomains to include NEWS_HEADLINE");

        newsStoryDomain.setText("News Story");
        newsStoryDomain.setToolTipText("Set traceMsgDomains to include NEWS_STORY");

        newsHeadlineReplayDomain.setText("News Headline Replay");
        newsHeadlineReplayDomain.setToolTipText("Set traceMsgDomains to include NEWS_HEADLINE_REPLAY");

        newsStoryReplayDomain.setText("News Story Replay");
        newsStoryReplayDomain.setToolTipText("Set traceMsgDomains to include NEWS_STORY_REPLAY");

        transactionDomain.setText("Transaction");
        transactionDomain.setToolTipText("Set traceMsgDomains to include TRANSACTION");

        marketPriceDomain.setText("Market Price");
        marketPriceDomain.setToolTipText("Set traceMsgDomains to include MARKET_PRICE");

        symbolListDomain.setText("Symbol List");
        symbolListDomain.setToolTipText("Set traceMsgDomains to include SYMBOL_LIST");

        yieldCurveDomain.setText("Yield Curve");
        yieldCurveDomain.setToolTipText("Set traceMsgDomains to include YIELD_CURVE");

        loginDomain.setText("Login");
        loginDomain.setToolTipText("Set traceMsgDomains to include LOGIN");

        marketByOrderDomain.setText("Market By Order");
        marketByOrderDomain.setToolTipText("Set traceMsgDomains to include MARKET_BY_ORDER");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(normalDomains)
                    .addComponent(jLabel2)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(historyDomain)
                            .addComponent(newsStoryDomain)
                            .addComponent(newsStoryReplayDomain)
                            .addComponent(dictionaryDomain)
                            .addComponent(marketMakerDomain)
                            .addComponent(transactionDomain)
                            .addComponent(loginDomain)
                            .addComponent(marketByPriceDomain))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(marketByOrderDomain)
                            .addComponent(yieldCurveDomain)
                            .addComponent(symbolListDomain)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(newsHeadlineReplayDomain, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(newsHeadlineDomain)
                                .addComponent(rankedSymbolListDomain)
                                .addComponent(marketPriceDomain)
                                .addComponent(directoryDomain)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(normalDomains)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(directoryDomain)
                    .addComponent(loginDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dictionaryDomain)
                    .addComponent(marketPriceDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(marketByPriceDomain)
                    .addComponent(marketByOrderDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(marketMakerDomain)
                    .addComponent(symbolListDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(historyDomain)
                    .addComponent(rankedSymbolListDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(newsStoryDomain)
                    .addComponent(newsHeadlineDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(newsStoryReplayDomain)
                    .addComponent(newsHeadlineReplayDomain))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(transactionDomain)
                    .addComponent(yieldCurveDomain))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        cancelDomain.setText("Cancel");
        cancelDomain.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelDomainActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        mountTrace.setText("Mount Trace");
        mountTrace.setToolTipText("Enables or disables detailed tracing of the connection process");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mountTrace)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mountTrace)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(okButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cancelDomain))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelDomain)
                    .addComponent(okButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        entryOk = true;
        this.setVisible(false);

        int ipcTraceFlags = 0;
        if (inputTracing.isSelected()) ipcTraceFlags += 1;
        if (outputTracing.isSelected()) ipcTraceFlags += 2;
        if (genericDataTracing.isSelected()) ipcTraceFlags += 4;
        if (hexDataTracing.isSelected()) ipcTraceFlags += 8;
        if (xmlDataTracing.isSelected()) ipcTraceFlags += 16;

        String traceDomains = "";
        if (this.normalDomains.isSelected()) {
            traceDomains = "NORMAL";
        } else {
            if (this.loginDomain.isSelected()) traceDomains += ",LOGIN";
            if (this.directoryDomain.isSelected()) traceDomains += ",DIRECTORY";
            if (this.dictionaryDomain.isSelected()) traceDomains += ",DICTIONARY";
            if (this.marketPriceDomain.isSelected()) traceDomains += ",MARKET_PRICE";
            if (this.marketByPriceDomain.isSelected()) traceDomains += ",MARKET_BY_PRICE";
            if (this.marketByOrderDomain.isSelected()) traceDomains += ",MARKET_BY_ORDER";
            if (this.marketMakerDomain.isSelected()) traceDomains += ",MARKET_MAKER";
            if (this.symbolListDomain.isSelected()) traceDomains += ",SYMBOL_LIST";
            if (this.rankedSymbolListDomain.isSelected()) traceDomains += ",RANKED_SYMBOL_LIST";
            if (this.historyDomain.isSelected()) traceDomains += ",HISTORY";
            if (this.newsHeadlineDomain.isSelected()) traceDomains += ",NEWS_HEADLINE";
            if (this.newsStoryDomain.isSelected()) traceDomains += ",NEWS_STORY";
            if (this.newsHeadlineReplayDomain.isSelected()) traceDomains += ",NEWS_HEADLINE_REPLAY";
            if (this.newsStoryReplayDomain.isSelected()) traceDomains += ",NEWS_STORY_REPLAY";
            if (this.transactionDomain.isSelected()) traceDomains += ",TRANSACTION";
            if (this.yieldCurveDomain.isSelected()) traceDomains += ",YIELD_CURVE";

            if (traceDomains.length()>0) traceDomains = traceDomains.substring(1);
        }
        
        userOptions.storeTraceOptionVals(
                mountTrace.isSelected(),
                ipcTraceFlags, 
                traceDomains);
    }//GEN-LAST:event_okButtonActionPerformed

    private void cancelDomainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelDomainActionPerformed
        entryOk = false;
        this.setVisible(false);
    }//GEN-LAST:event_cancelDomainActionPerformed

    private void normalDomainsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_normalDomainsItemStateChanged
        boolean state = normalDomains.isSelected();
        this.loginDomain.setEnabled(!state);
        this.directoryDomain.setEnabled(!state);
        this.dictionaryDomain.setEnabled(!state);
        this.marketPriceDomain.setEnabled(!state);
        this.marketByPriceDomain.setEnabled(!state);
        this.marketByOrderDomain.setEnabled(!state);
        this.marketMakerDomain.setEnabled(!state);
        this.symbolListDomain.setEnabled(!state);
        this.rankedSymbolListDomain.setEnabled(!state);
        this.historyDomain.setEnabled(!state);
        this.newsHeadlineDomain.setEnabled(!state);
        this.newsStoryDomain.setEnabled(!state);
        this.newsHeadlineReplayDomain.setEnabled(!state);
        this.newsStoryReplayDomain.setEnabled(!state);
        this.transactionDomain.setEnabled(!state);
        this.yieldCurveDomain.setEnabled(!state);
        if ( state == true ) {
            this.loginDomain.setSelected(!state);
            this.directoryDomain.setSelected(!state);
            this.dictionaryDomain.setSelected(!state);
            this.marketPriceDomain.setSelected(!state);
            this.marketByPriceDomain.setSelected(!state);
            this.marketByOrderDomain.setSelected(!state);
            this.marketMakerDomain.setSelected(!state);
            this.symbolListDomain.setSelected(!state);
            this.rankedSymbolListDomain.setSelected(!state);
            this.historyDomain.setSelected(!state);
            this.newsHeadlineDomain.setSelected(!state);
            this.newsStoryDomain.setSelected(!state);
            this.newsHeadlineReplayDomain.setSelected(!state);
            this.newsStoryReplayDomain.setSelected(!state);
            this.transactionDomain.setSelected(!state);
            this.yieldCurveDomain.setSelected(!state);
        }
    }//GEN-LAST:event_normalDomainsItemStateChanged

    private void setCurrentValues() {
        if (userOptions != null) {
            mountTrace.setSelected( userOptions.getMountTrace() );
            
            int ipcTraceFlags = userOptions.getIpcTraceFlags();
            this.inputTracing.setSelected( (ipcTraceFlags & 0x1) != 0 );
            this.outputTracing.setSelected( (ipcTraceFlags & 0x2) != 0 );
            this.genericDataTracing.setSelected( (ipcTraceFlags & 0x4) != 0 );
            this.hexDataTracing.setSelected( (ipcTraceFlags & 0x8) != 0 );
            this.xmlDataTracing.setSelected( (ipcTraceFlags & 0x10) != 0 );
            
            String traceDomains = userOptions.getTraceMsgDomains();
            if ( traceDomains.contains("NORMAL") ) normalDomains.setSelected(true); else normalDomains.setSelected(false);
            if ( traceDomains.contains("LOGIN") ) loginDomain.setSelected(true); else loginDomain.setSelected(false);
            if ( traceDomains.contains("DIRECTORY") ) directoryDomain.setSelected(true); else directoryDomain.setSelected(false);
            if ( traceDomains.contains("DICTIONARY") ) dictionaryDomain.setSelected(true); else dictionaryDomain.setSelected(false);
            if ( traceDomains.contains("MARKET_PRICE") ) marketPriceDomain.setSelected(true); else marketPriceDomain.setSelected(false);
            if ( traceDomains.contains("MARKET_BY_PRICE") ) marketByPriceDomain.setSelected(true); else marketByPriceDomain.setSelected(false);
            if ( traceDomains.contains("MARKET_BY_ORDER") ) marketByOrderDomain.setSelected(true); else marketByOrderDomain.setSelected(false);
            if ( traceDomains.contains("MARKET_MAKER") ) marketMakerDomain.setSelected(true); else marketMakerDomain.setSelected(false);
            if ( traceDomains.startsWith("SYMBOL_LIST") || traceDomains.contains(",SYMBOL_LIST") ) symbolListDomain.setSelected(true); else symbolListDomain.setSelected(false);
            if ( traceDomains.contains("RANKED_SYMBOL_LIST") ) rankedSymbolListDomain.setSelected(true); else rankedSymbolListDomain.setSelected(false);
            if ( traceDomains.contains("HISTORY") ) historyDomain.setSelected(true); else historyDomain.setSelected(false);
            if ( traceDomains.contains("NEWS_HEADLINE") ) newsHeadlineDomain.setSelected(true); else newsHeadlineDomain.setSelected(false);
            if ( traceDomains.contains("NEWS_STORY") ) newsStoryDomain.setSelected(true); else newsStoryDomain.setSelected(false);
            if ( traceDomains.contains("NEWS_HEADLINE_REPLAY") ) newsHeadlineReplayDomain.setSelected(true); else newsHeadlineReplayDomain.setSelected(false);
            if ( traceDomains.contains("NEWS_STORY_REPLAY") ) newsStoryReplayDomain.setSelected(true); else newsStoryReplayDomain.setSelected(false);
            if ( traceDomains.contains("TRANSACTION") ) transactionDomain.setSelected(true); else transactionDomain.setSelected(false);
            if ( traceDomains.contains("YIELD_CURVE") ) yieldCurveDomain.setSelected(true); else yieldCurveDomain.setSelected(false);
        }
    }
    
    public boolean getOptions() {
        setCurrentValues();
        this.setLocationRelativeTo( parentFrame );
        this.setVisible(true);
        
        return entryOk;
    }
    

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TraceOptions.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TraceOptions.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TraceOptions.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TraceOptions.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TraceOptions dialog = new TraceOptions(null, new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    private Frame parentFrame = null;
    private UserOptions userOptions = null;
    private boolean entryOk = false;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelDomain;
    private javax.swing.JCheckBox dictionaryDomain;
    private javax.swing.JCheckBox directoryDomain;
    private javax.swing.JCheckBox genericDataTracing;
    private javax.swing.JCheckBox hexDataTracing;
    private javax.swing.JCheckBox historyDomain;
    private javax.swing.JCheckBox inputTracing;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JCheckBox loginDomain;
    private javax.swing.JCheckBox marketByOrderDomain;
    private javax.swing.JCheckBox marketByPriceDomain;
    private javax.swing.JCheckBox marketMakerDomain;
    private javax.swing.JCheckBox marketPriceDomain;
    private javax.swing.JCheckBox mountTrace;
    private javax.swing.JCheckBox newsHeadlineDomain;
    private javax.swing.JCheckBox newsHeadlineReplayDomain;
    private javax.swing.JCheckBox newsStoryDomain;
    private javax.swing.JCheckBox newsStoryReplayDomain;
    private javax.swing.JCheckBox normalDomains;
    private javax.swing.JButton okButton;
    private javax.swing.JCheckBox outputTracing;
    private javax.swing.JCheckBox rankedSymbolListDomain;
    private javax.swing.JCheckBox symbolListDomain;
    private javax.swing.JCheckBox transactionDomain;
    private javax.swing.JCheckBox xmlDataTracing;
    private javax.swing.JCheckBox yieldCurveDomain;
    // End of variables declaration//GEN-END:variables
}
